#include "cube.h"
#include <stdio.h>
#include <GL/glut.h>

using namespace std;

Cube::Cube(float w, float h, float d, float *m)
{
    if (m)
    {
	for (int i = 0; i < 4 * 4; ++i)
	{
	    _m[i] = m[i];
	}
    }
    else
    {
	for (int i = 0; i < 4 * 4; ++i)
	{
	    _m[i] = 0.0;
	}

	_m[0] = 1.0;
	_m[5] = 1.0;
	_m[10] = 1.0;
	_m[15] = 1.0;
    }

    width = w;
    height = h;
    depth = d;
}

void Cube::renderInLocalFrame() const
{
//    printf("renderInLocalFrame:\n");
//    for (int i = 0; i < 16; ++i)
//    {
//	printf("%2.4f, ", _m[i]);
//    }
//    printf("\n");
    glScalef(width, height, depth);
    glColor3ubv(color);
    glutSolidCube(1.0f);
}
